package com.gouda.temporary.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Properties;

public class ConfigUtils {

    private static final Logger log = LoggerFactory.getLogger(ConfigUtils.class);

    private static Properties properties = new Properties();

    private static String jdbcUrl;

    private static String jdbcUserName;

    private static String jdbcPassword;

    private static String corpID;

    private static String corpSecret;

    static {
        try {
            properties.load(ConfigUtils.class.getClassLoader().getResourceAsStream("config.properties"));

            jdbcUrl = properties.getProperty("jdbc.url");
            jdbcUserName = properties.getProperty("jdbc.username");
            jdbcPassword = properties.getProperty("jdbc.password");
            corpID = properties.getProperty("corp.corpID");
            corpSecret = properties.getProperty("corp.Secret");

            log.info("jdbc.url={}, jdbc.username={}, jdbc.password={}, corp.corpID={}, corp.secret={}",
                      jdbcUrl, jdbcUserName, jdbcPassword, corpID, corpSecret);
        } catch (Exception e) {
            log.error("config.properties load fail.", e);
        }
    }


    public static String getJdbcUrl() {
        return jdbcUrl;
    }

    public static String getJdbcUserName() {
        return jdbcUserName;
    }

    public static String getJdbcPassword() {
        return jdbcPassword;
    }

    public static String getCorpID() {
        return corpID;
    }

    public static String getCorpSecret() {
        return corpSecret;
    }

    private ConfigUtils() {}
}
